﻿


using System.Windows.Ink;
using System.Windows.Input;
using System.Collections.Generic;
using System;

[Serializable]
public class DiagramStrokes
{
    [Serializable]
    public class DiagramStylusPoint
    {
        public double X;
        public double Y;
        public float Pressure;
        public DiagramStylusPoint(double X, double Y, float Pressure)
        {
            this.X = X;
            this.Y = Y;
            this.Pressure = Pressure;
        }
    }

    [Serializable]
    public class DiagramStroke
    {
        public List<DiagramStylusPoint> lista = new List<DiagramStylusPoint>();
        public Stroke toStroke()
        {            
            StylusPointCollection spc = new StylusPointCollection();
            foreach (DiagramStylusPoint dsp in lista)
            {
                spc.Add(new StylusPoint(dsp.X, dsp.Y, dsp.Pressure));
            }

            Stroke s = new Stroke(spc);            
            return s;
        }
    }

    public static StrokeCollection pobierzStrolki(List<DiagramStroke> strokes)
    {
        StrokeCollection s = new StrokeCollection();
        s.Clear();
        foreach (DiagramStroke ds in strokes)
        {
            s.Add(ds.toStroke());
        }
        strokes.Clear();
        strokes = null;
        return s;
    }

    public static List<DiagramStroke> stworzStrolki(StrokeCollection s)
    {
        List<DiagramStroke> strokes = new List<DiagramStroke>();
        foreach (Stroke str in s)
        {
            DiagramStroke dS = new DiagramStroke();
            foreach (StylusPoint sp in str.StylusPoints)
            {
                dS.lista.Add(new DiagramStylusPoint(sp.X, sp.Y, sp.PressureFactor));
            }
            strokes.Add(dS);
        }
        s.Clear();
        s = null;
        return strokes;
    }
}